home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************\
-
- File: ls.c
-
- Purpose: This module handles game initialization/shutdown and
- starting new games (from scratch or from disk).
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program in a file named "GNU General Public License".
- If not, write to the Free Software Foundation, 675 Mass Ave,
- Cambridge, MA 02139, USA.
-
- \**********************************************************************/
-
- #include "ls.h"
- #include "program globals.h"
- #include "graphics.h"
- #include "file interface.h"
- #include "error.h"
- #include "menus.h"
- #include "ls load-save.h"
- #include "ls endgame.h"
- #include "ls find.h"
- #include "ls main window.h"
-
- short gNumRows, gNumColumns;
- short gCurrentRow, gCurrentColumn;
- short gNumMoves;
- short Board[MAX_ROWS][MAX_COLS];
- Point gMoves[MAX_ROWS*MAX_COLS];
- CIconHandle gTheCIcon[10];
- Handle gTheIcon[10];
-
- void InitTheProgram(void)
- {
- short i,j,k;
- AppFile myFile;
-
- CallIndDispatchProc(kHelp, kStartup, 0L);
- SetIndDispatchProc(kMainWindow, MainWindowDispatch);
- CallIndDispatchProc(kMainWindow, kStartup, 0L);
-
- InitTheEndGame();
- InitFind();
-
- CountAppFiles(&i, &j);
- if ((j>0) && (i==0))
- {
- GetAppFiles(1, &myFile);
- MyMakeFSSpec(myFile.vRefNum, 0, myFile.fName, &gameFile);
- HandleError(GetSavedGame(&gameFile), FALSE);
- for (k=1; k<=j; k++)
- ClrAppFiles(k);
- }
- }
-
- void NewGame(void)
- {
- short i,j;
-
- // init game globals here, stuff that would be saved to disk in saved game
- for (i=0; i<MAX_ROWS; i++)
- for (j=0; j<MAX_COLS; j++)
- Board[i][j]=0;
- gNumMoves=0;
- gCurrentRow=gCurrentColumn=0;
- InitLoadSave();
- StartGame();
- }
-
- void StartGame(void)
- {
- // init game globals here, stuff that always needs to be initted
- OpenTheIndWindow(kMainWindow);
- AdjustMenus();
- DrawMenuBar();
- }
-
- void ShutDownTheProgram(void)
- {
- ShutDownTheEndGame();
- CallIndDispatchProc(kMainWindow, kShutdown, 0L);
- }
-